package com.gxxy.spring.kp03_aop.cls01_proxy.s1_static;

public class StudentServiceProxy implements IStudentService {
	
	// proxy
	// delegate

	private StudentServiceImpl service;

	public StudentServiceProxy(StudentServiceImpl service) {
		this.service = service;
	}

	@Override
	public void save(Student stu) {
		try {
			System.out.println("beginTransaction();");

			service.save(stu);
			service.update(stu);

			System.out.println("commit();");
		} catch (Exception e) {
			System.out.println("rollback();");
		} finally {
			System.out.println("执行完毕");
		}
	}

	@Override
	public void update(Student stu) {
		System.out.println("beginTransaction();");

		service.update(stu);

		System.out.println("commit();");
	}

}
